/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import sun.misc.BASE64Encoder;
import javax.ejb.EJB;

/**
 *
 * @author carlos
 */
@ManagedBean(name = "encriptaSenha")
@SessionScoped
public class EncriptaSenha {

      public static String encripta (String senha) {
           try {
                MessageDigest digest = MessageDigest.getInstance("MD5");
                digest.update(senha.getBytes());
                BASE64Encoder encoder = new BASE64Encoder ();
                return encoder.encode (digest.digest ());
           } catch (NoSuchAlgorithmException ns) {
                return senha;
           }
      }
 }
